package 拷贝;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-02
 * Time: 14:44
 */
class Money{
    public double money = 58.5;

}
class Person implements Cloneable{
    public int age =10;
    public Money m = new Money();

    @Override
    protected Object clone() throws CloneNotSupportedException {
       return super.clone();
//        Person tmp =(Person)super.clone();
//        tmp.m=(Money) this.m.clone();
//        return tmp;
    }
}
public class Test {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person = new Person();
        Person person1=(Person)person.clone();
        System.out.println(person.m.money);
        System.out.println(person1.m.money);
        System.out.println("==========改变后========");
        person1.m.money = 15.5;
        System.out.println(person.m.money);
        System.out.println(person1.m.money);



    }
}
